package servlet;

import dao.BooksDao;
import dao.impl.BooksDaoImpl;
import pojo.Books;
import service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class BookServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BooksDao booksDao =  new BooksDaoImpl();
        BookServiceImpl bookService = new BookServiceImpl();

        bookService.setBooksDao(booksDao);
        List<Books> booksList = bookService.getBookList();
        request.setAttribute("booksList",booksList);
//        System.out.println("+++++++++++++");
        request.getRequestDispatcher("/libraryManagement.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
